<%--
  Created by IntelliJ IDEA.
  User: liufh
  Date: 2020/8/26
  Time: 17:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>装维信息</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../resources/weuiTest/css/weui.css"/>
    <link rel="stylesheet" href="../resources/weuiTest/css/weuix.css"/>
    <script src="../resources/weuiTest/js/zepto.min.js"></script>
    <script src="../resources/weuiTest/js/zepto.weui.js"></script>
    <script src="../resources/weuiTest/js/php.js"></script>
</head>

<body ontouchstart>
<div class="page-hd">
    <h1 class="page-hd-title">
        装维信息
    </h1>
<%--    <p class="page-hd-desc">向下无限加载</p>--%>
</div>
<div class="weui-panel weui-panel_access">
    <div class="weui-panel__bd" id="rank-list">  </div>
    <div class="weui-panel__ft">
        <a href="javascript:void(0);" class="weui-cell weui-cell_access weui-cell_link">
            <div class="weui-cell__bd" id="getmore">查看更多<i id="loading" class="weui-loading"></i></div>

        </a>
    </div>
</div>
<%--<br>--%>
<%--<br>--%>
<%--<div class="weui-footer weui-footer_fixed-bottom">--%>
<%--    <p class="weui-footer__links">--%>
<%--        <a href="../index.html" class="weui-footer__link">WeUI首页</a>--%>
<%--    </p>--%>
<%--    <p class="weui-footer__text">Copyright &copy; Yoby</p>--%>
<%--</div>--%>

<script>
    $('#loading').hide();
    var pagesize=8;//每页数据条数
    function ajaxpage(page){
        $.ajax({
            type:"post",
            url:'/app/work/queryList/'+page+'/'+pagesize,//'../php/page.php',
            data: {"page":page, "pagesize":pagesize, ajax:2},
            dataType:'json',
            timeout:10000,
            beforeSend:function(xhr){
                $('#loading').show();
            },
            success:function(rs){
                $('#loading').hide();
                var html = "";
                var list = rs.data;
                for (var i in list) {
                    html += '<a href="/app/work/toDeviceDetail?accessNum='+ list[i].accessNum +'&custName=' + list[i].custName + '&eqptTypeName='+ list[i].eqptTypeName +'" class="weui-media-box weui-media-box_appmsg">';
                    html += '<div class="weui-media-box__bd">';
                    html += '<h4 class="weui-media-box__title">客户名称: ' + list[i].custName + '</h4>';
                    html += '<p class="weui-media-box__desc">接入号: ' + list[i].accessNum + '</p>';
                    html += '</div>';
                    html += '</a>';
                }
                $("#rank-list").append(html);

                var maxpage = Math.ceil(rs.total / pagesize);
                sessionStorage['maxpage'] = maxpage;
                if(page==maxpage){
                    $("#getmore").html("没有更多数据了");return false;
                }
            },
            error:function(xhr){
                alert('ajax出错');
            },
        });
    }

    $(function(){
        var page = 2;
        var maxpage;
        $('#getmore').on('click', function() {
            maxpage = sessionStorage['maxpage'];
            if(page<=maxpage) {
                ajaxpage(page);
                page++;
            }
        });
        ajaxpage(1);
    })
</script>
</body>
</html>
